package org.meb.speedway.dao;

import javax.inject.Inject;

import org.meb.speedway.config.General;
import org.meb.speedway.model.registry.League;
import org.meb.speedway.model.registry.Team;

public class DaoResolver {

	@Inject
	private LeagueDao leagueDao;
	@Inject
	private TeamDao teamDao;
	@Inject
	@General
	private BaseDao<?> dao;

	@SuppressWarnings("unchecked")
	public <T> BaseDao<T> resolve(Class<T> clazz) {
		if (clazz == League.class) {
			return (BaseDao<T>) leagueDao;
		} else if (clazz == Team.class) {
			return (BaseDao<T>) teamDao;
		} else {
			return (BaseDao<T>) dao;
		}
	}
}
